package com.mutual.assistance.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mutual.assistance.constant.StringConstant;
import com.mutual.assistance.exception.BizException;
import com.mutual.assistance.exception.code.ExceptionCode;
import com.mutual.assistance.response.PageParams;
import com.mutual.assistance.response.PageResult;
import com.mutual.assistance.user.constant.RedisConstant;
import com.mutual.assistance.user.converter.UserConverterParams;
import com.mutual.assistance.user.mapper.RoleMapper;
import com.mutual.assistance.user.mapper.UserMapper;
import com.mutual.assistance.user.mapper.UserNoticeMapper;
import com.mutual.assistance.user.mapper.UserRoleMapper;
import com.mutual.assistance.user.model.bo.UserMessageBO;
import com.mutual.assistance.user.model.dto.RoleSimpleDto;
import com.mutual.assistance.user.model.dto.UserAndRoleDTO;
import com.mutual.assistance.user.model.dto.UserDTO;
import com.mutual.assistance.user.model.dto.UserNoticeDTO;
import com.mutual.assistance.user.model.po.RolePO;
import com.mutual.assistance.user.model.po.UserNoticePO;
import com.mutual.assistance.user.model.po.UserPO;
import com.mutual.assistance.user.model.po.UserRolePO;
import com.mutual.assistance.user.model.vo.*;
import com.mutual.assistance.user.service.MailSenderService;
import com.mutual.assistance.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static com.mutual.assistance.exception.code.ExceptionCode.*;
import static com.mutual.assistance.user.constant.RedisConstant.RESET_PASSWORD_CODE_KEY;

/**
 * @author chenyuxin
 * @version 1.0
 * @description 用户服务实现类
 * @date 2023/4/17 16:40
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Resource
    private UserConverterParams userConverterParams;

    @Resource
    private UserRoleMapper userRoleMapper;

    @Resource
    public StringRedisTemplate stringRedisTemplate;

    @Resource
    private PasswordEncoder passwordEncoder;

    @Resource
    private MailSenderService mailSenderService;

    @Resource
    private RoleMapper roleMapper;

    @Resource
    private UserNoticeMapper userNoticeMapper;

    @Override
    @Transactional
    public void register(RegisterUserVO registerUserVo) {
        log.info("获取到注册信息：{}", registerUserVo);

        String code = registerUserVo.getCode();
        String redisCode = stringRedisTemplate.opsForValue().get(RedisConstant.REGISTER_CODE_KEY);
        if (!code.equals(redisCode)) {
            log.error("验证码无效：{}", code);
            throw new BizException(ExceptionCode.INVALID_VERIFICATION_CODE.getCode(), ExceptionCode.INVALID_VERIFICATION_CODE.getMsg());
        }

        String username = registerUserVo.getUsername();
        UserPO userPO = getUserPOByUserName(username);

        String email = registerUserVo.getEmail();
        checkUserPOByEmail(email);

        String password = registerUserVo.getPassword();
        String passwordEncode = passwordEncoder.encode(password);
        registerUserVo.setPassword(passwordEncode);
        if (userPO != null) {
            log.info("数据库中已经存在该角色记录， username：{}", username);
            throw new BizException(REPEAT_ADDITION.getCode(), username + REPEAT_ADDITION.getMsg());
        }
        UserPO insertUser = userConverterParams.registerUserVo2UserPO(registerUserVo);

        log.info("转换后：{}", insertUser);
        String nickname = registerUserVo.getNickname();
        if (StringUtils.isEmpty(nickname)) {
            insertUser.setNickname(registerUserVo.getUsername());
        }
        int insert = userMapper.insert(insertUser);
        if (insert < 0) {
            log.error("用户注册失败");
            throw BizException.wrap(ExceptionCode.SQL_EX.getCode(),
                    ExceptionCode.SQL_EX.getMsg() + "username: " + username + "用户注册失败");
        }
        UserPO userPODB = getUserPOByUserName(username);
        UserRolePO userRolePO = new UserRolePO();
        userRolePO.setUserId(userPODB.getId());
        userRolePO.setRoleId(StringConstant.COMMON_USER_ROLE_ID);
        userRolePO.setCreateTime(LocalDateTime.now());
        log.info("插入中间表UserRole数据：{}", userRolePO);
        int insertUserRole = userRoleMapper.insert(userRolePO);
        if (insertUserRole < 0) {
            log.error("赋予角色失败");
            throw BizException.wrap(ExceptionCode.SQL_EX.getCode(),
                    ExceptionCode.SQL_EX.getMsg() + "username: " + username
                            + "赋予角色失败：" + StringConstant.COMMON_USER_ROLE_ID);
        }
    }

    @Override
    public UserDTO getUserById(String userId) {
        log.info("用户id：{}", userId);
        UserPO userPO = userMapper.selectOne(new LambdaQueryWrapper<UserPO>().eq(UserPO::getId, userId));
        log.info("获取到用户信息：{}", userPO);
        if (userPO == null) {
            log.error("该角色未登录或者用户不存在：{}", userId);
            throw new BizException(THE_USER_IS_NOT_LOGGED_IN_OR_THE_USER_DOES_NOT_EXIST.getCode(),
                    userId + THE_USER_IS_NOT_LOGGED_IN_OR_THE_USER_DOES_NOT_EXIST.getMsg());
        }
        return userConverterParams.userPO2UserDTO(userPO);
    }

    @Override
    @Transactional
    public void deleteUser(List<String> userIds) {
        log.info("删除的用户id：{}", userIds);
        for (String userId : userIds) {
            int delete = userRoleMapper.delete(new LambdaQueryWrapper<UserRolePO>()
                    .eq(UserRolePO::getUserId, userId));
            if (delete < 0) {
                log.error("删除用户角色失败");
                throw BizException.wrap(ExceptionCode.SQL_EX.getCode(),
                        ExceptionCode.SQL_EX.getMsg() + "userId: " + userId
                                + "删除用户角色失败：" + StringConstant.COMMON_USER_ROLE_ID);
            }
        }

        int deleteUsers = userMapper.deleteBatchIds(userIds);

        if (deleteUsers < 0) {
            log.error("删除用户失败");
            throw BizException.wrap(ExceptionCode.SQL_EX.getCode(),
                    ExceptionCode.SQL_EX.getMsg() + "userIds: " + userIds + "删除用户失败：");
        }
    }

    @Override
    public PageResult<UserDTO> getAllUserMessage(PageParams pageParams, QueryUserParamsVO queryUserParamsVO) {
        log.info("获取到前端传入参数pageParams：{}, queryUserParamsVO：{}", pageParams, queryUserParamsVO);
        LambdaQueryWrapper<UserPO> queryWrapper = new LambdaQueryWrapper<>();

        String username = queryUserParamsVO.getUsername();
        log.info("获取到用户名：{}", username);
        queryWrapper.like(username != null, UserPO::getUsername, username);

        String sex = queryUserParamsVO.getSex();
        log.info("获取用户性别：{}", sex);
        queryWrapper.eq(sex != null, UserPO::getSex, sex);

        String status = queryUserParamsVO.getStatus();
        log.info("获取到用户状态：{}", status);
        queryWrapper.eq(status != null, UserPO::getStatus, status);

        Integer star = queryUserParamsVO.getStar();
        log.info("获取到用户星级：{}", star);
        queryWrapper.eq(star != null, UserPO::getStar, star);

        Integer credit = queryUserParamsVO.getCredit();
        log.info("获取到用户积分：{}", credit);
        queryWrapper.eq(credit != null, UserPO::getCredit, credit);


        //分页对象
        Page<UserPO> page = new Page<>(pageParams.getPageNo(), pageParams.getPageSize());
        // 查询数据内容获得结果
        Page<UserPO> pageResult = userMapper.selectPage(page, queryWrapper);
        // 获取数据列表
        List<UserPO> list = pageResult.getRecords();
        log.info("获取到集合列表：{}", list);
        List<UserDTO> userDTOS = userConverterParams.userPO2UserDTOList(list);
        log.info("获取到转换集合列表：{}", userDTOS);
        // 获取数据总数
        long total = pageResult.getTotal();
        return new PageResult<>(userDTOS, total, pageParams.getPageNo(), pageParams.getPageSize());
    }

    @Override
    public void updatePersonalMessage(UpdateUserPersonalParamsVO updateUserPersonalParamsVO, String userId) {
        UserPO userPODB = getUserPOById(userId);
        String password = updateUserPersonalParamsVO.getPassword();
        if (StringUtils.isNotBlank(password)) {
            log.info("开始加密");
            updateUserPersonalParamsVO.setPassword(passwordEncoder.encode(password));
        }

        UserPO userPO = userConverterParams.updateUserPersonalParamsVO2UserPO(updateUserPersonalParamsVO);

        updateUser(userPODB.getId(), userPO);
    }

    @Override
    public void updateUserMessage(UpdateUserParamsVO updateUserParamsVO) {
        log.info("获取到前端请求参数：{}", updateUserParamsVO);
        String userId = updateUserParamsVO.getId();
        getUserPOById(userId);
        UserPO userPO = userConverterParams.updateUserParamsVO2UserPO(updateUserParamsVO);
        log.info("获取转换数据：{}", userPO);
        updateUser(Long.valueOf(userId), userPO);
    }


    @Override
    public UserAndRoleDTO getUserAndRole(String userId) {
        UserPO userPO = getUserPOById(userId);
        UserAndRoleDTO userAndRoleDTO = userConverterParams.userPO2UserAndRoleDTO(userPO);
        log.info("获取到转换参数：{}", userAndRoleDTO);
        List<UserRolePO> userRolePOList = userRoleMapper.selectList(new LambdaQueryWrapper<UserRolePO>()
                .eq(UserRolePO::getUserId, userId));
        log.info("获取到角色与用户对应表：{}", userRolePOList);
        if (CollectionUtils.isEmpty(userRolePOList)) {
            userAndRoleDTO.setRoleDTOList(null);
            return userAndRoleDTO;
        }
        List<RoleSimpleDto> roleDTOList = new ArrayList<>();
        for (UserRolePO userRolePO : userRolePOList) {
            log.info("遍历中间表：{}", userRolePO);
            RolePO rolePO = roleMapper.selectOne(new LambdaQueryWrapper<RolePO>()
                    .eq(RolePO::getId, userRolePO.getRoleId()));
            log.info("获取到角色属性：{}", rolePO);
            RoleSimpleDto roleSimpleDto = userConverterParams.rolePO2RoleSimpleDto(rolePO);
            log.info("获取到转换属性：{}", roleSimpleDto);
            roleDTOList.add(roleSimpleDto);
        }
        log.info("添加集合：{}", roleDTOList);
        userAndRoleDTO.setRoleDTOList(roleDTOList);
        return userAndRoleDTO;
    }

    @Override
    public List<UserAndRoleDTO> getAllUserAndRole() {
        List<UserPO> userPOList = userMapper.selectList(null);
        List<String> userIds = new ArrayList<>();
        for (UserPO userPO : userPOList) {
            userIds.add(userPO.getId().toString());
        }
        log.info("获取到用户集合：{}", userIds);
        List<UserAndRoleDTO> list = new ArrayList<>();
        for (String userId : userIds) {
            log.info("获取到用户主键：{}", userId);
            UserAndRoleDTO userAndRole = getUserAndRole(userId);
            log.info("获取到用户与角色信息：{}", userAndRole);
            list.add(userAndRole);
        }
        return list;
    }

    @Override
    public void deleteUserRole(String userId, String roleId) {
        getUserPOById(userId);
        LambdaQueryWrapper<UserRolePO> queryWrapper = new LambdaQueryWrapper<UserRolePO>()
                .eq(UserRolePO::getUserId, userId)
                .eq(roleId != null, UserRolePO::getRoleId, roleId);
        List<UserRolePO> userRolePOList = userRoleMapper.selectList(queryWrapper);
        if (CollectionUtils.isEmpty(userRolePOList)) {
            log.info("获取到该用户拥有角色：{}", userRolePOList);
            log.error("对应角色不存在");
            throw new BizException(ExceptionCode.DATABASE_FIELD_DOES_NOT_EXIST.getCode(),
                    ExceptionCode.DATABASE_FIELD_DOES_NOT_EXIST.getMsg());
        }
        int delete = userRoleMapper.delete(queryWrapper);
        if (delete < 0) {
            log.error("删除失败");
            throw new BizException(ExceptionCode.SQL_EX.getCode(),
                    ExceptionCode.SQL_EX.getMsg());
        }
    }

    @Override
    public void addUserRole(AddUserAndRoleParamsVO addUserAndRoleParamsVO) {
        String userId = addUserAndRoleParamsVO.getUserId();
        String roleId = addUserAndRoleParamsVO.getRoleId();
        getUserPOById(userId);
        log.info("获取到角色id：{}", roleId);
        RolePO rolePO = roleMapper.selectOne(new LambdaQueryWrapper<RolePO>().eq(RolePO::getId, roleId));
        if (rolePO == null) {
            log.error("对应角色不存在");
            throw new BizException(ExceptionCode.DATABASE_FIELD_DOES_NOT_EXIST.getCode(),
                    ExceptionCode.DATABASE_FIELD_DOES_NOT_EXIST.getMsg() + ": " + roleId);
        }
        UserRolePO userRolePO = userConverterParams.addUserAndRoleParamsVO2UserRolePO(addUserAndRoleParamsVO);
        log.info("转换后参数：{}", userRolePO);
        int insert = userRoleMapper.insert(userRolePO);
        if (insert < 0) {
            log.error("添加失败");
            throw new BizException(ExceptionCode.SQL_EX.getCode(),
                    ExceptionCode.SQL_EX.getMsg());
        }
    }

    @Override
    public void retrievePassword(RetrievePasswordVO retrievePasswordVO) {
        String username = retrievePasswordVO.getUsername();
        log.info("获取到用户：{}", username);
        UserPO po = getUserPOByUserName(username);
        if (po == null) {
            log.error("该用户不存在");
            throw new BizException(THE_USER_IS_NOT_LOGGED_IN_OR_THE_USER_DOES_NOT_EXIST.getCode(),
                    THE_USER_IS_NOT_LOGGED_IN_OR_THE_USER_DOES_NOT_EXIST.getMsg());
        }
        String code = retrievePasswordVO.getCode();
        String codeR = stringRedisTemplate.opsForValue().get(RESET_PASSWORD_CODE_KEY);
        log.info("获取到验证码：存储：{}, 用户发送：{}", codeR, code);
        if (codeR == null || !codeR.equals(code)) {
            throw new BizException(ExceptionCode.INVALID_VERIFICATION_CODE.getCode(),
                    ExceptionCode.INVALID_VERIFICATION_CODE.getMsg());
        }
        UserPO userPO = new UserPO();
        String password = retrievePasswordVO.getPassword();
        String encode = passwordEncoder.encode(password);
        userPO.setPassword(encode);
        int update = userMapper.update(userPO, new LambdaQueryWrapper<UserPO>()
                .eq(UserPO::getUsername, retrievePasswordVO.getUsername()));
        if (update < 0) {
            log.error("更新失败");
            throw new BizException(ExceptionCode.SQL_EX.getCode(),
                    ExceptionCode.SQL_EX.getMsg());
        }
    }

    public static final String RETRIEVE_PASSWORD = "学生管理系统找回密码";
    public static final String RETRIEVE_PASSWORD_CODE = "找回密码验证码为：";

    @Override
    public void sendEmail(String username) {
        UserPO userPO = getUserPOByUserName(username);
        if (userPO == null) {
            log.error("用户不存在：{}", username);
            throw new BizException(THE_USER_IS_NOT_LOGGED_IN_OR_THE_USER_DOES_NOT_EXIST.getCode(),
                    THE_USER_IS_NOT_LOGGED_IN_OR_THE_USER_DOES_NOT_EXIST.getMsg());
        }
        String email = userPO.getEmail();
        if (StringUtils.isBlank(email)) {
            log.info("无效的邮箱");
            throw new BizException(ExceptionCode.EMAIL_DOES_NOT_EXIST.getCode(), ExceptionCode.EMAIL_DOES_NOT_EXIST.getMsg());
        }

        String code = RandomUtils.nextInt(1000, 9999) + "";
        stringRedisTemplate.opsForValue().set(RESET_PASSWORD_CODE_KEY, code, 5, TimeUnit.MINUTES);
        mailSenderService.sendSimpleMail(email, RETRIEVE_PASSWORD, RETRIEVE_PASSWORD_CODE + code);
    }

    @Override
    public void subscriberUserCredit(String username, Integer credit) {
        synchronized (username.intern()) {
            if (credit <= 0) {
                log.info("操作的任务积分小于等于0");
                throw new BizException(CREDIT_ERROR.getCode(), "操作的" + CREDIT_ERROR.getMsg());
            }

            UserPO userPODB = getUserByUsername(username);

            String status = userPODB.getStatus();
            checkUserStatus(status);

            log.info("要扣减的积分");
            Integer userCredit = userPODB.getCredit();
            if (userCredit <= 0 || userCredit < credit) {
                log.info("用户积分不足");
                throw new BizException(INSUFFICIENT_POINTS.getCode(), INSUFFICIENT_POINTS.getMsg());
            }

            int update = userMapper.subscriberUserCredit(username, credit);
            if (update <= 0) {
                log.info("更新失败");
                throw new BizException(ExceptionCode.SQL_EX.getCode(), ExceptionCode.SQL_EX.getMsg());
            }
        }

    }

    @NotNull
    private UserPO getUserByUsername(String username) {
        UserPO userPODB = getUserPOByUserName(username);
        if (userPODB == null) {
            log.error("数据库不存在的字段");
            throw new BizException(DATABASE_FIELD_DOES_NOT_EXIST.getCode(), DATABASE_FIELD_DOES_NOT_EXIST.getMsg());
        }
        return userPODB;
    }

    @Override
    public void createUserMessage(UserMessageBO message) {
        log.info("获取到消息队列传入参数：{}", message);
        UserNoticePO userNoticePO = userConverterParams.userMessageBO2UserNoticePO(message);
        log.info("获取到转换参数：{}", userNoticePO);
        int insert = userNoticeMapper.insert(userNoticePO);
        if (insert <= 0) {
            log.error("插入失败");
            throw new BizException(ExceptionCode.SQL_EX.getCode(), ExceptionCode.SQL_EX.getMsg());
        }
    }

    @Override
    @Transactional
    public PageResult<UserNoticeDTO> getUserAllMessage(PageParams pageParams, String username) {
        log.info("获取到前端响应参数：{}", pageParams);
        LambdaQueryWrapper<UserNoticePO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UserNoticePO::getUsername, username);
        // 修改状态为已读
        UserNoticePO userNoticePO = new UserNoticePO();
        userNoticePO.setStatus(StringConstant.READ);
        int update = userNoticeMapper.update(userNoticePO, queryWrapper);
        if (update <= 0) {
            log.error("更新失败");
            throw new BizException(ExceptionCode.SQL_EX.getCode(),
                    ExceptionCode.SQL_EX.getMsg());
        }

        // 获取所有信息
        Page<UserNoticePO> page = new Page<>(pageParams.getPageNo(), pageParams.getPageSize());
        Page<UserNoticePO> pageResult = userNoticeMapper.selectPage(page, queryWrapper);
        log.info("获取到分页参数：{}", pageResult);
        List<UserNoticePO> records = pageResult.getRecords();
        List<UserNoticeDTO> userNoticeDTOS = userConverterParams.userNoticePO2UserNoticeDTOList(records);
        long total = pageResult.getTotal();
        return new PageResult<>(userNoticeDTOS, total, pageParams.getPageNo(), pageParams.getPageSize());
    }

    @Override
    @Transactional
    public void deleteUserMessage(String username, String messageId) {
        LambdaQueryWrapper<UserNoticePO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(messageId != null, UserNoticePO::getId, messageId);
        queryWrapper.eq(UserNoticePO::getUsername, username);

        Integer count = userNoticeMapper.selectCount(queryWrapper);
        log.info("查询消息个数为：{}", count);
        if (count <= 0) {
            log.error("该消息已经不存在");
            throw new BizException(ExceptionCode.DATABASE_FIELD_DOES_NOT_EXIST.getCode(),
                    ExceptionCode.DATABASE_FIELD_DOES_NOT_EXIST.getMsg());
        }

        int delete = userNoticeMapper.delete(queryWrapper);
        log.info("删除的个数为：{}", delete);
        if (delete <= 0) {
            log.error("删除失败");
            throw BizException.wrap(SQL_EX.getCode(), SQL_EX.getMsg() + "username：{}" + username);
        }

    }

    @Override
    public void rollbackCredit(String username, Integer credit) {
        log.info("获取到用户name：{}, 回滚积分：{}", username, credit);
        UserPO userPO = getUserByUsername(username);
        log.info("获取到用户信息：{}", userPO);
        String status = userPO.getStatus();
        checkUserStatus(status);
        int update = userMapper.rollbackCredit(username, credit);
        if (update < 0) {
            log.error("更新用户积分失败");
            throw BizException.wrap(SQL_EX.getCode(), SQL_EX.getMsg() + "username：{}", username);
        }
    }

    @Override
    public UserDTO getUserByUserName(String username) {
        log.info("获取到用户名称：{}", username);
        UserPO userPO = getUserPOByUserName(username);
        if (userPO == null) {
            log.error("用户不存在");
            throw new BizException(INVALID_OBJECT.getCode(), INVALID_OBJECT.getMsg() + username + "不存在");
        }
        log.info("获取到转换前的参数：{}", userPO);
        UserDTO userDTO = userConverterParams.userPO2UserDTO(userPO);
        log.info("获取到转换后的参数：{}", userDTO);
        return userDTO;
    }

    @Override
    public void updateUserStarByUsername(String username, Integer star) {
        log.info("获取到用户名：{}，获取到聚合星级：{}", username, star);
        UserPO userPO = getUserByUsername(username);
        checkUserStatus(userPO.getStatus());
        int userStar = userMapper.updateUserStar(username, star);
        if (userStar <= 0) {
            log.error("更新用户星级失败");
            throw new BizException(SQL_EX.getCode(), SQL_EX.getMsg() + "username：" + username);
        }
    }


    private void checkUserStatus(String status) {
        if (StringConstant.MALE.equals(status)) {
            log.error("该用户已被禁用");
            throw new BizException(DISABLED_USER.getCode(), DISABLED_USER.getMsg());
        }
    }


    private void updateUser(Long userId, UserPO userPO) {
        log.info("获取转换后对象：{}", userPO);
        int update = userMapper.update(userPO, new LambdaQueryWrapper<UserPO>().eq(UserPO::getId, userId));
        if (update < 0) {
            log.error("更新用户失败");
            throw BizException.wrap(SQL_EX.getCode(), SQL_EX.getMsg() + "userId：{}", userId);
        }
    }

    private UserPO getUserPOByUserName(String username) {
        return userMapper.selectOne(new LambdaQueryWrapper<UserPO>().eq(UserPO::getUsername, username));
    }

    private UserPO getUserPOById(String userId) {
        log.info("获取到用户id：{}", userId);
        UserPO userPODB = userMapper.selectOne(new LambdaQueryWrapper<UserPO>().
                eq(UserPO::getId, userId));
        log.info("获取用户数据库数据：{}", userPODB);
        if (userPODB == null) {
            log.error("用户不存在：{}", userId);
            throw new BizException(THE_USER_IS_NOT_LOGGED_IN_OR_THE_USER_DOES_NOT_EXIST.getCode(),
                    THE_USER_IS_NOT_LOGGED_IN_OR_THE_USER_DOES_NOT_EXIST.getMsg());
        }
        return userPODB;
    }

    private void checkUserPOByEmail(String email) {
        UserPO userPO = userMapper.selectOne(new LambdaQueryWrapper<UserPO>().eq(UserPO::getEmail, email));
        if (userPO != null) {
            log.error("该邮箱已注册，请重试， email：{}", email);
            throw new BizException(REPEAT_ADDITION.getCode(), email + REPEAT_ADDITION.getMsg());
        }
    }
}
